<?php

require_once 'class.account.php';

class news extends account {
	
	public $property = array();
	
	public function __construct()
	{
		$this -> open();
	}
	
	public function getData()
	{
		return $this -> property;
	}
	
	public function setData($query)
	{
		$this -> query($query);
	
			while($rd = $this -> fetch())
			{
				$this -> property[] = $rd;
			}
		return $this;
	}
	
	public function newsView()
	{
		$newsView = $this -> setData("SELECT * FROM news ORDER BY news_date DESC LIMIT 0,10") -> getData();

		$box = '';
		
		for($i = 0; $i < count($newsView); $i++)
		{
			$author_id = $newsView[$i]['news_author'];
			$author_name = $this -> accountTraslateId($author_id);
			
			$box .= '<h2>' . htmlentities($author_name) . '</h2>
					<strong>' . $newsView[$i]['news_date'] . '</strong> 
					<p>' . $newsView[$i]['news_content'] . '</p>';
		}
		
		return $box;
	}
	
	

}

?>